Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acknowledge packets asynchronously #1392

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

sug0
Copy link
Contributor

@sug0 sug0 commented Jan 15, 2025

Potentially related to #361

Description

This PR introduces the ability to acknowledge IBC packets asynchronously, bringing ibc-rs's API closer to ibc-go.

These changes were required in order to implement the packet forward middleware on top of ibc-rs.


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests (tested through IBC Packet Forward Middleware anoma/namada#4082)
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

sug0 added a commit to heliaxdev/cosmos-ibc-rs that referenced this pull request Jan 15, 2025
@sug0
Copy link
Contributor Author

sug0 commented Jan 15, 2025

cc @rnbguy

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 73.00000% with 27 lines in your changes missing coverage. Please review.

Project coverage is 67.07%. Comparing base (36944b8) to head (2adeb6b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...-core/ics04-channel/src/handler/acknowledgement.rs 70.37% 24 Missing ⚠️
...rc/testapp/ibc/applications/nft_transfer/module.rs 0.00% 2 Missing ⚠️
ibc-core/ics04-channel/src/handler/recv_packet.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1392      +/-   ##
==========================================
- Coverage   67.09%   67.07%   -0.03%     
==========================================
  Files         226      226              
  Lines       22425    22485      +60     
==========================================
+ Hits        15047    15082      +35     
- Misses       7378     7403      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sug0, thanks for upstreaming the changes! I’ve requested a few updates. In addition to those, it would be great if you could:

  1. select "Allow edits from maintainers" so we can move quickly on fixing minor findings
  2. Update the README under ibc-core: https://github.com/cosmos/ibc-rs/tree/main/ibc-core#asynchronous-acknowledgements
  3. Update your branch once add optional arbitrary impls #1390 merged.

4. (If there is) share a pointer to your codebase where this changes has been integrated to better understand your use case.

ibc-apps/ics20-transfer/src/context.rs Outdated Show resolved Hide resolved
ibc-apps/ics20-transfer/src/module.rs Outdated Show resolved Hide resolved
ibc-core/ics04-channel/src/handler/acknowledgement.rs Outdated Show resolved Hide resolved
ibc-core/ics04-channel/src/handler/acknowledgement.rs Outdated Show resolved Hide resolved
sug0 added a commit to heliaxdev/cosmos-ibc-rs that referenced this pull request Jan 16, 2025
@sug0 sug0 force-pushed the tiago/optional-ack-rebased branch from b388e85 to 2bfea0b Compare January 16, 2025 13:17
@sug0 sug0 requested a review from Farhad-Shabani January 16, 2025 13:19
sug0 added a commit to heliaxdev/cosmos-ibc-rs that referenced this pull request Jan 17, 2025
@sug0 sug0 force-pushed the tiago/optional-ack-rebased branch from 2bfea0b to 6c30f13 Compare January 17, 2025 10:17
sug0 added a commit to heliaxdev/cosmos-ibc-rs that referenced this pull request Jan 17, 2025
@sug0 sug0 force-pushed the tiago/optional-ack-rebased branch from 6c30f13 to f6b68fe Compare January 17, 2025 10:24
@sug0 sug0 force-pushed the tiago/optional-ack-rebased branch from f6b68fe to 2adeb6b Compare January 17, 2025 10:37
@sug0 sug0 mentioned this pull request Jan 17, 2025
7 tasks
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything's set! Thanks so much!

@@ -0,0 +1,2 @@
- Support asynchronous packet acknowledgements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Support asynchronous packet acknowledgements.
- [ibc-core] Support asynchronous packet acknowledgements.

ibc-core/ics04-channel/src/handler/acknowledgement.rs Outdated Show resolved Hide resolved
Comment on lines +126 to +147
/// ICS-26 `onRecvPacket` callback implementation.
///
/// # Note on optional acknowledgements
///
/// Acknowledgements can be committed asynchronously, hence
/// the `Option` type. In general, acknowledgements should
/// be committed to storage, accompanied by an ack event,
/// as soon as a packet is received. This will be done
/// automatically as long as `Some(ack)` is returned from
/// this callback. However, in some cases, such as when
/// implementing a multiple hop packet delivery protocol,
/// a packet can only be acknowledged after it has reached
/// the last hop.
///
/// ## Committing a packet asynchronously
///
/// Event emission and state updates for packet acknowledgements
/// can be performed asynchronously using [`emit_packet_acknowledgement_event`]
/// and [`commit_packet_acknowledgment`], respectively.
///
/// [`commit_packet_acknowledgment`]: ../../channel/handler/fn.commit_packet_acknowledgment.html
/// [`emit_packet_acknowledgement_event`]: ../../channel/handler/fn.emit_packet_acknowledgement_event.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Much appreciated!

@Farhad-Shabani Farhad-Shabani added this pull request to the merge queue Jan 17, 2025
Merged via the queue into cosmos:main with commit 27f10ac Jan 17, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants